#include <cstdio>
#include <cstring>

char a[ 100001 ], b[ 100001 ], t1[ 200001 ], t2[ 200001 ];
int next[ 100001 ];

void getnext( char *a, int *next )
{
    int i = 1, j = -1;
    next[ 0 ] = -1;
    while ( a[ i ] )
    {
        while ( j >= 0 && a[ j + 1 ] != a[ i ] ) j = next[ j ];
        if ( a[ j + 1 ] == a[ i ] ) j++;
        next[ i++ ] = j;
    }
}

int match( char *a, char *b )
{
    int i = 0, j = -1;
    while ( a[ i ] )
    {
        while ( j >= 0 && b[ j + 1 ] != a[ i ] ) j = next[ j ];
        if ( b[ j + 1 ] == a[ i ] ) j++;
        if ( !b[ j + 1 ] && a[ i + 1 ] ) j = next[ j ];
        i++;
    }
    return j;
}

int main( )
{
    int i;
    while ( scanf("%s%s", a, b) != EOF )
    {
        memset( t1, 0, sizeof( t1 ) );
        memset( t2, 0, sizeof( t2 ) );
        getnext( b, next );
        i = match( a, b ) + 1;
        memcpy( t1, a, strlen( a ) );
        memcpy( t1 + strlen( a ), b + i, strlen( b ) - i );
        getnext( a, next );
        i = match( b, a ) + 1;
        memcpy( t2, b, strlen( b ) );
        memcpy( t2 + strlen( b ), a + i, strlen( a ) - i );
        if ( strlen( t1 ) < strlen( t2 ) )
            puts( t1 );
        else
            if ( strlen( t1 ) > strlen( t2 ) )
                puts( t2 );
            else
                if ( strcmp( t1, t2 ) < 0 )
                    puts( t1 );
                else
                    puts( t2 );
    }
    return 0;
}
